package com.woniu.product.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.woniu.product.client.result.CategoryiInfo;
import com.woniu.product.client.CategoryQueryClient;
import com.woniu.product.service.CategoryService;
import com.woniu.product.service.dto.CategoryDto;
import com.woniu.result.Result;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
@RestController
public class CategoryQueryApiImpl implements CategoryQueryClient {
    @Resource
    private CategoryService categoryService;
    @Override
    public Result<List<CategoryiInfo>> selCategory() throws JsonProcessingException {
        List<CategoryDto> categoryDtoList = categoryService.selCategory();
        List<CategoryiInfo> categoryiInfos = BeanUtil.copyToList(categoryDtoList, CategoryiInfo.class);
        return  Result.getInstanceList(CategoryiInfo.class).setData(categoryiInfos);
    }
}
